package com.xiaoyao.novel.proxy;

import java.io.IOException;
import java.util.Properties;

import com.xiaoyao.novel.util.HttpUtil;
import com.xiaoyao.novel.util.SpendClock;

public class ProxyTest {
	private static final String username = "域\\用户";
	private static final String password = "密码";
	// 默认 用户IP:58.251.146.253,type:request.getRemoteAddr() 
	private static final String host = "112.5.16.50"; //用户IP:183.237.24.87,type:x-forwarded-for 
	private static final String port = "80";
//	private static final String host = "101.18.169.169"; //  用户IP:101.18.169.169,type:request.getRemoteAddr() 
//	private static final String port = "18186";
//	private static final String host = "111.240.131.180  "; //   用户IP:111.240.131.180,type:request.getRemoteAddr()  
//	private static final String port = "9064";
//	private static final String host = "174.36.178.106  "; //    
//	private static final String port = "80";
//	private static final String host = "119.254.102.89"; //       
//	private static final String port = "8080";

	public static void initProxy() {
		Properties props = System.getProperties();
		props.setProperty("proxySet", "true");
		props.setProperty("http.proxyHost", host.trim());
		props.setProperty("http.proxyPort", port.trim());
		// Authenticator.setDefault(new Authenticator() {
		// protected PasswordAuthentication getPasswordAuthentication() {
		// return new PasswordAuthentication(username,
		// new String(password).toCharArray());
		// }
		// });
	}

	public static void main(String[] args) throws IOException {
		initProxy() ;
		SpendClock.start() ;
		HttpUtil httpUtil = new HttpUtil("UTF-8");
		String urlStr = "http://www.tianfengfeiye.com/testip.jsp";
		String page = httpUtil.getPage(urlStr);
		System.out.println("返回页面:"+page);
		SpendClock.print() ;
	}
	
	
	
	
}
